<!DOCTYPE htm>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>多个元素或组件的过渡</title>
  <script src="./vue.js"></script>
  <style>
    .fade-enter, .fade-leave-to {
      opacity: 0;
    }
    .fade-enter-active, .fade-leave-active {
      transition: 1s;
    }
  </style>
</head>
<body>
  <div id="root">
    <!-- mode 使用 先进入再隐藏 -->
    <transition name="fade" mode="in-out">
      <!-- 使用v-if 没有加key会导致dom复用 不会有动画效果 -->
      <div v-if="show" key="hello">hello world</div>
      <div v-else key="bye">bye world</div>
    </transition>
    <button @click="handleClick">Toggle</button>
  </div>

  <script>
  
    var vm = new Vue({
      el: '#root',
      data: {
        show: true
      },
      methods: {
        handleClick: function() {
          this.show = !this.show;
        }
      }
    })
  </script>
</body>
</html>